﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class MergeCellUi : BaseUi
{
    public Transform tileTransform;
    public Transform objTransform;
    public Image objImage;
    public int index;
    void Start()
    {
        float width = rt.rect.width;
        float height = rt.rect.height;
        float pWidth = transform.parent.GetComponent<RectTransform>().rect.width;
        float pHeight = transform.parent.GetComponent<RectTransform>().rect.height;
        float x = (index % 4 - 1.5f) * pWidth / 4;
        float y = -(Mathf.Floor(index / 4) - 1) * pHeight / 3;
        rt.offsetMin = new Vector2(x - width / 2, y - height / 2);
        rt.offsetMax = new Vector2(x + width / 2, y + height / 2);
        refreshObj();
    }
    public void refreshObj()
    {
        objTransform.gameObject.SetActive(Model.mergeGrid[index] != 0);
    }
    void OnMouseDown()
    {
        Debug.Log("on mouse down");
    }
    public void OnPointerEnter(PointerEventData eventData)
    {

        Debug.Log("OnPointerEnter");
    }
}
